﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Diablo3.Engine;
using Diablo3.Engine.Property;

namespace Diablo3.Window
{
    public partial class ItemsControl : UserControl
    {
        public ItemsControl()
        {
            InitializeComponent();
            this.SetStyle(ControlStyles.DoubleBuffer, true);//设置双缓冲区
            this.SetStyle(ControlStyles.UserPaint, true);//由控件自行绘制，而不是通过操作系统绘制
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);//忽略WM_ERASEBACKGROUND窗口消息
        }

        public Items Items { get; set; }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            if (Items != null)
            {
                //物品名称
                e.Graphics.DrawString(Items.ItemsName, this.Font, SystemBrushes.ControlText, 10, 8);
                e.Graphics.DrawLine(SystemPens.ControlText, 10, 24, this.Width - 10, 24);

                //物品属性
                for(int i = 0;i < Items.Properties.Count;i++)
                {
                    e.Graphics.DrawString(((ItemsProperty)Items.Properties[i]).Des,this.Font, SystemBrushes.ControlText, 10,32 + (i * 16));
                }
            }
            else
            {
                e.Graphics.DrawString("装备", this.Font, SystemBrushes.ControlText, 10, 8);
                e.Graphics.DrawLine(SystemPens.ControlText,10, 24, this.Width - 10, 24);
            }
        }
    }
}
